<?php
/**
 * @version 	$Id: fRegistry.class.php 74 2010-03-17 06:48:21Z mylifeisskidrow@gmail.com $
 * @author 		$Author: mylifeisskidrow@gmail.com $
 * @copyright 	Copyright (c) 2010 Luu Trong Hieu. All right reserved.
 * @license 	GNU/GPL see license.php
 */

defined('IN_FLYWHEEL') or die('Restricted Access');
/**
 * Registry
 * 
 * @package 	system
 *
 */
class fRegistry {
	private $registry;
	public function __construct() {}
	
	/**
	 * Set
	 *
	 * @param string $name
	 * @param instance $object
	 * @param string $namespace. Default = 'system'
	 * @return true if set success, false if exist regitry object
	 */
	public function set($name, $object, $namespace = 'system') {
		if (!isset($this->registry[$namespace][$name])) {
			$this->registry[$namespace][$name] = $object;					
		}
		return false;		
	}
	
	/**
	 * get
	 *
	 * @param string $name
	 * @param string $namespace. Default = 'system'
	 * @return object
	 */
	public function get($name, $namespace = 'system') {
		return $this->registry[$namespace][$name];		
	}
	
	/**
	 * has
	 *
	 * @param string $name
	 * @param string $namespace. Default = 'system'
	 * @return boolean
	 */
	public function has($name, $namespace = 'system') {
		return isset($this->registry[$namespace][$name]);		
	}
	
	private function __clone() {}
}